
package com.hmsg.health.controller;


import com.hmsg.health.bean.vo.*;
import com.hmsg.health.dao.AdminSystemDao;
import com.hmsg.health.dao.UserDao;
import com.hmsg.health.service.CommonService;
import com.hmsg.health.service.MenWangSMSService;
import com.hmsg.health.service.TaskService;
import com.hmsg.health.service.UserService;
import com.hmsg.health.service.aes.SecurityData;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.Base64Utils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSBuilder;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.PutObjectResult;
import com.aliyuncs.http.HttpResponse;
import com.hmsg.health.bean.domain.AdminSystemDo;
import com.hmsg.health.bean.domain.BannerDo;
import com.hmsg.health.bean.domain.TaskDo;
import com.hmsg.health.bean.domain.UserDo;
import com.hmsg.health.bean.enums.StatusCode;
import com.hmsg.health.config.Constants;
import com.hmsg.health.config.PropertyConfig;
import com.hmsg.health.param.AccessToken;
import com.hmsg.health.param.ResponseResult;
import com.hmsg.health.security.IgnoreSecurity;
import com.hmsg.health.security.OpenApi;
import com.hmsg.health.security.TokenManager;
import com.hmsg.health.utils.ApiException;
import com.hmsg.health.utils.ErrorCode;
import com.hmsg.health.utils.GetScene;
import com.hmsg.health.utils.HttpResult;
import com.hmsg.health.utils.HttpUtil;
import com.hmsg.health.utils.RandomUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.Base64;
import java.util.Base64.Decoder;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author Tareva on 2018/11/11.
 * @Description TODO
 */
@Api(value = "首页相关", tags = { "首页相关" })
@Slf4j
@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
	StringRedisTemplate stringTemplate;
    @Autowired
  	private MenWangSMSService smsService;
	@Autowired
	private TokenManager tokenManager;
    static final String XCODE_KEY = "XCODE_KEY_";
    @Autowired
  	PropertyConfig propertyConfig;
    @Autowired
    private UserService userService;
    @Autowired
    private TaskService taskService;
    
    @Autowired
    private AdminSystemDao adminSystemDao;
    @Autowired
    private CommonService commonService;
    @GetMapping("/banners")
    @ApiOperation(value="首页banner", notes="首页banner" ,httpMethod="GET")
    @ResponseBody
    @IgnoreSecurity
	@OpenApi
	@SecurityData
	public  ResponseResult<List<BannerDo>> banners() {
    	List<BannerDo> banners = commonService.selectBanner(new BannerDo());
    	
		return new ResponseResult<List<BannerDo>>(StatusCode.SYSTEM_SUCCESS, banners);
	}
    
    
    @GetMapping("/deploy")
    @ApiOperation(value="发布任务金币列表", notes="首页banner" ,httpMethod="GET")
    @ResponseBody
    @IgnoreSecurity
	@OpenApi
	@SecurityData
	public  ResponseResult<List<BannerDo>> deploy() {
    	List<BannerDo> banners = commonService.selectBanner(new BannerDo());
    	
		return new ResponseResult<List<BannerDo>>(StatusCode.SYSTEM_SUCCESS, banners);
	}
    
    
    @GetMapping("/sysinfo")
    @ApiOperation(value="应用开关", notes="应用开关" ,httpMethod="GET")
    @ResponseBody
    @IgnoreSecurity
	@OpenApi
	@SecurityData
	public  ResponseResult<AdminSystemDo> sysinfo() {
    	AdminSystemDo sysinfo = adminSystemDao.find();
		return new ResponseResult<AdminSystemDo>(StatusCode.SYSTEM_SUCCESS, sysinfo);
	}
    
    
   
	
}

